package ncku.account.event.old;

import java.util.Scanner;

import ncku.account.data.GlobalData;
import ncku.account.data.old.Account;
import ncku.account.event.Export;
import ncku.account.event.LineChart;

//根據使用者輸入的功能代碼,分派由哪個java檔執行
public class FunctionVisitor {
	public int function=0;
	private int endingFunctionNumber = 10;  //離開程式的數字代碼
	public GlobalData globalData;
	
	Scanner scanner = new Scanner(System.in);
	listTransaction show = new listTransaction();  //ListTransaction object
	
	public FunctionVisitor(){
		globalData = new GlobalData();
	}
	public void Start(){
		while(function != endingFunctionNumber){  //若無輸入離開程式指令
			printMenu();
			chooseFunction();
		}
	}
	
	//印出功能介面(暫時)
	public void printMenu(){
		System.out.println("===============Menu==============");
		System.out.println("1.Add a new account");
		System.out.println("2.Add a new transaction");
		System.out.println("3.Show all transactions");
		System.out.println("4.Edit a transaction");
		System.out.println("5.Delete a transaction");
		System.out.println("6.Show information of account");
		System.out.println("7.Pie Graphed");
		System.out.println("8.Bar Graphed");
		System.out.println("9.Line Graphed");
		System.out.println("10.Close this program");
		System.out.println("11.Import Account");
		System.out.println("12.Export Account");
		
		System.out.println("===============Menu==============");
		System.out.print("Please input a function number:");
		function = Integer.valueOf(scanner.next());
	}
	
	//根據輸入的數字指令,分派執行
	public void chooseFunction(){
		switch(function){
			case 1:  //Add a new account
				Account account = new Account();
				account.accountAdd();	
				break;
			case 2:  //Add a new transaction
				try {
					AddTransaction add = new AddTransaction();			
					
				} catch (Exception e) {
					// TODO Auto-generated catch block
					System.out.println(e);
				}
				break;
			case 3:  //Show all transactions
				show.listTransaction();
				break;
			case 4:  //Edit a transaction
				try{
					EditTransaction edit = new EditTransaction();  //editTransaction object
				}
				catch(Exception e){
					System.out.println(e);	
				}
				break;
			case 5: //Delete a transaction
				try{
					DeleteTransaction delete = new DeleteTransaction();  //deleteTransaction object
				}
				catch(Exception e){
					System.out.println(e);	
				}
				break;
			case 6:  //Show information of account
				break;
			case 7:  //Pie Graphed
				//PieChart.showpie();
				break;
			case 8:  //Bar Graphed
				//BarChart.showbar();
				break;
			case 9:  //Line Graphed
			    LineChart.showline();
				//break;
			case 10:  //Close the program
				break;
			case 11:  //Import
				/*Import Import = new Import();
				Import.Start();*/
				break;
			case 12:  //Export
				Export export = new Export();
				export.Start();
				break;
			default:
				System.out.print("You key in the wrong number!");
				break;
		}//end of switch 
	}
}




